package com.jake.microservice.provider.mybatis.service.impl;

import com.jake.microservice.model.UserDTO;
import com.jake.microservice.model.UserInfoDTO;
import com.jake.microservice.provider.mybatis.mapper.UserMapper;
import com.jake.microservice.provider.mybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<UserDTO> findAllUsers() {
        return userMapper.findAllUsers();
    }

    @Override
    public List<UserDTO> findAllUserInfo() {
        return userMapper.findAllUserInfo();
    }

    @Override
    public UserDTO findUserById(Integer uid) {
        return userMapper.findUserById(uid);
    }

    @Override
    public UserInfoDTO findUserInfoById(Integer uid) {
        return userMapper.findUserInfoById(uid);
    }

    @Override
    public List<UserInfoDTO> findUserInfoByUsernameAndCname(String username, String cname) {
        return userMapper.findUserInfoByUsernameAndCname(username, cname);
    }

    @Override
    public int createUser(UserDTO user) {
        return userMapper.insertUser(user);
    }

    @Override
    public int updateUser(UserDTO user) {
        return userMapper.updateUser(user);
    }

    @Override
    public int updateUsername(String username, Integer uid) {
        return userMapper.updateUsername(username, uid);
    }

    @Override
    public int removeUserById(Integer uid) {
        return userMapper.deleteUserById(uid);
    }

}
